home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / Font.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  31.4 KB  |  744 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Font.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    KTA, KL, ML, GS et al
  9. #
  10. #    Copyright:    © 1993-1995 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    1.0.112>    11/13/95    ML        ReportSelectedMenuItems - pass params into
  19. #                                    gReportSelectedMenuItems
  20. #    .0.111+>    11/13/95    ML        ReportSelectedMenuItems - pass params into gReportSelectedMenuItems
  21. #    1.0.111>     2/24/95    KTA        ReportSelectedMenuItems() - Check to see if globa gNextLine is
  22. #                                    defined before calling it.
  23. #    1.0.110>     2/24/95    KTA        ReportSelectedMenuItems() - changed default         from 0 to
  24. #                                    ''.
  25. #    <1.0.19>     2/24/95    KTA        ReportSelectedMenuItems() - Added default of 0 for pObjectNumber
  26. #                                    to avoid vu errors
  27. #    <1.0.18>     2/21/95    KTA        ReportSelectedMenuItems() - removed
  28. #                                    gReportSelectedMenuItemsHook1
  29. #    <1.0.17>     1/27/95    KTA        ReportSelectedMenuItems() - added gReportSelectedMenuItemsHook1
  30. #    <1.0.16>     12/1/94    ML        Added Exception Handling support
  31. #    1.0.15+>     12/1/94    ML        Added Exception Handling support
  32. #    <1.0.15>     5/12/94    KTA        SetFont(), SetStyle(), SetSize() - Wasn't handling disabled
  33. #                                    menuItems correctly.
  34. #    1.0.13+>    11/19/93    NAGA        modify TCS format
  35. #    <1.0.13>     9/22/93    KTA        Removed gHandleTextEntry as no one was using it.
  36. #    <1.0.12>     9/13/93    KTA        Updated TestLevel specification.
  37. #    <1.0.11>     8/30/93    KTA        Updated task headers and parameters.
  38. #    <1.0.10>     8/25/93    KTA        Added support for parity checking the TCS stack.
  39. #     <1.0.9>     7/30/93    KTA        Added checks in SetStyle(), SetSize(), SetFont() to see if
  40. #                                    menuItem is enabled.  If not TCSReturn :=  -1.
  41. #     <1.0.8>     7/23/93    KTA        SetStyle() - gCurrStyleMenu - Help insure that it is initilized
  42. #                                    correctly.
  43. #     <1.0.7>     7/14/93    KTA        International Support: See InitFonts(),
  44. #                                    ReportSelectedMenuItems(), SetFont(), SetStyle(), SetSize(). Now
  45. #                                    depends on Output.Lib.
  46. #     <1.0.5>      6/8/93    NAGA        unmark tasks that are not to be published
  47. #    <1.0.3>         5/21/93    NAGA        Adding header and porting old files to follow new standards
  48. #
  49. # ****************************************************************************
  50. #
  51.  
  52. ########################################################################
  53. #                            External libraries 
  54. #=======================================================================
  55. Libraries "TCS.Lib","UserInterface.Lib", "OutPut.Lib", "ExceptionHandling.Lib";
  56.  
  57.  
  58. #########################################################################
  59. #                                Font.Lib
  60. #========================================================================
  61. # Description:    This module contains VU code for exercising fonts, styles, and
  62. #                sizes.  There are three modes of font testing currently defined.
  63. #                These can be executed by calling DoText with certain globals set 
  64. #                appropriately. The following section details the proper global
  65. #                settings to execute the various test methods.
  66. #                All of the methods are based on the execution of a FontRecord which
  67. #                consists of three elements {"FontName", "SizeName", {StyleList}};
  68. #                For example: ourFontRecord := {'Geneva','12',{'Bold','Italic'}};
  69. #                
  70. #
  71. #                                        ---- globals ----
  72. #                In order to execute any of the font testing methods there are a  
  73. #                series of globals that must be defined in the Task-InitFonts();
  74. #
  75. #                All font characteristics are generated from the predefined global
  76. #                font lists: gFontList, gFontSizeList, gFontStyleList. 
  77. #                Define these lists with appropriate Fonts, Sizes and Styles.
  78. #                These are the first block of globals in InitFontglobals();
  79. #                
  80. #                DO NOT define the second block of globals (gCurrFontMenu, gCurrSizeMenu,
  81. #                gCurrStyleMenu). These globals will be automatically defined. They 
  82. #                store the titles to the menus which contain the font characteristic 
  83. #                menu items.
  84. #                
  85. #                The global gPlainStyle should be defined as the menu item which clears
  86. #                all font styles.
  87. #
  88. #                The global gNextLineMethod should be defined as the appropriate method
  89. #                which a particular application requires to be prepared to enter the 
  90. #                next line of text.
  91. #                
  92. #                The global gNextLineClearsFontSettings should be set to a 1 if the 
  93. #                method of moving to the next line of text clears all the font settings. 
  94. #                It should be set to 0 if moving to the next line retains the font 
  95. #                settings - ( important if the test method is kWaterFall - see below)
  96. #                
  97. #
  98. #                                    ---- TEST METHODS ----
  99. #            • Generate Random FontRecords -
  100. #                1) Set gFontLevel to equal kRandomText. (i.e. global gFontLevel := kRandomText;)
  101. #                2) Set NumTimes input parameter to equal the number of random text records. 
  102. #                    DoText(3,5); # For 5 random text records
  103. #                3) Call DoText();
  104. #
  105. #                - The FontRecord generated will include a random Font, a random size,
  106. #                    and a random number of random styles.
  107. #
  108. #            • QuickLook method -
  109. #                1) Set gFontLevel to equal kQLFontTest. (i.e. global gFontLevel := kQLFontTest;)
  110. #                2) Call DoText();
  111. #
  112. #                - This will generated 1 FontRecord for each font with a random size and
  113. #                    a random combination of styles.
  114. #
  115. #            • WaterFall method -
  116. #                1) Set gFontLevel to equal kWaterFall. (i.e. global gFontLevel := kWaterFall;)
  117. #                2) Be sure the global gNextLineClearsFontSettings is set correctly (See above)
  118. #                3) Call DoText();
  119. #
  120. #                - This will generated 1 FontRecord for each font with every size and combination 
  121. #                    of styles.
  122. #                    For example the first record may be {"Helvetica", '12', {'Bold'}}; and the 
  123. #                    second record might be {"Helvetica", '12', {'Bold', 'italic'}}
  124. #
  125. #     Copyright Apple Computer, Inc. 1985-1991
  126. #    All rights reserved
  127. #
  128. #========================================================================
  129. # History:
  130. #
  131. #########################################################################
  132.  
  133.     ##### Accessors ####
  134. task ReplaceFont(pCurrentFont,pCurrentFontRecord) begin return(Replace(pCurrentFont,1,pCurrentFontRecord)); end;
  135. task ReplaceFontSize(pCurrentSize,pCurrentFontRecord) begin return(Replace(pCurrentSize,2,pCurrentFontRecord)); end;
  136. task ReplaceFontStyle(pStyleList,pCurrentFontRecord) begin return(Replace(pStyleList,3,pCurrentFontRecord)); end;
  137.  
  138.  
  139. #########################################################################
  140. #                        InitFonts()
  141. #========================================================================
  142. # Author:        KTA
  143. # Description:    Initializes the font globals. 
  144. # Parameters:    None
  145. # Returns:        Nada
  146. # Examples:        InitFonts();
  147. # Assumptions:    
  148. #========================================================================
  149. # History:
  150. # KTA    7/8/93    Move gFontList, gFontStyleList, gFontSizeList to Globals.Lib (intl)
  151. #########################################################################
  152. TASK InitFonts()
  153. begin
  154.     #===== Task references =======
  155.     global gSetFont              := Task SetFont;        # Requires VU 2.0
  156.     global gSetSize              := Task SetSize;        # Requires VU 2.0
  157.     global gSetStyle             := Task SetStyle;        # Requires VU 2.0
  158.     global gNextLine             := Task NextLine;        # Requires VU 2.0
  159.     
  160.     global gFontObject            := 0;        # Object Number in a given suite
  161.  
  162.     #======= font characteristic lists  >> Moved to Globals.Lib =======
  163.     
  164.     #####################################################################
  165.     #### Do not change the values below!!! 
  166.     #### The following Globals are default values and if an application needs
  167.     #### to override them it should be done from within the script.  
  168.     #####################################################################
  169.         ### Name of the Plain (style) menu item  ####
  170.     global gPlainStyle := "Plain";            # Plain-Style menu item
  171.  
  172.         ### How to get to the next line
  173.     global gNextLineMethod := 1;            
  174.         ### 1 - ReturnKey,  2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
  175.     
  176.         ### Does moving to the next line clear all font info
  177.     global gNextLineClearsFontSettings := 1;                        
  178. end;
  179. #########################################################################
  180. #                        SetFont(pMyFont, pObjectNumber)
  181. #========================================================================
  182. # Author:        KTA
  183. # Description:    Selects <pMyFont> menuitem to set the current font.  
  184. # Parameters:    pMyFont - Name of the font.
  185. #                pObjectNumber - Integer used to track all elements that make up 
  186. #                                an Font record - TCS related.
  187. # Returns:        returns what SelectMenuItem returns 
  188. #                    0 - failure
  189. #                    String - success
  190. # Examples:        SetFont('Geneva');
  191. # Assumptions:    That InitFonts() has been called thus global gCurrFontMenu
  192. #                is set to the name of the menus which contain <pMyFont>
  193. #========================================================================
  194. # History:
  195. # KTA 7/8/93    gCurrFontMenu update for intl
  196. # KTA 7/30/93    TCSReturn -1 if menuItem is not enabled
  197. # KTA 8/24/93    TCS stack parity check
  198. # KTA 5/12/94    Wasn't handling disabled menuItems correctly.
  199. # ML 12/01/94    Added exception handling support
  200. #########################################################################
  201. TASK SetFont(pMyFont := '', pObjectNumber := 'NA') 
  202. begin
  203.     failStr := "";
  204.     returnVal := 0;
  205.     if not(global gCurrFontMenu)                # Menu(s) which contain the menu item
  206.     begin
  207.         gCurrFontMenu := FindMenu(global gFontList[1]);    
  208.         if not(gCurrFontMenu)                # Menu(s) which contain the menu item
  209.             gCurrFontMenu := FindMenu("Chicago");    
  210.     end;
  211.         
  212.     if (gCurrFontMenu)
  213.     begin
  214.         TCSStart({ 1, global kTCSetFont},"SetFont");        # Start TCS
  215.         returnVal := SelectMenuItem(pMyFont,gCurrFontMenu[1],gCurrFontMenu[2]);    # Select the font from the Font menu
  216.         if (returnVal)
  217.             myReturn := 1;
  218.         else    # No returnVal - SelectMenuItem failed
  219.         begin
  220.             if (gCurrFontMenu[2])
  221.                 theMenuItem :=  _match([menuItem t:pMyFont m:[menuItem t:gCurrFontMenu[1] m:[menu t:gCurrFontMenu[2]]]]!,1);
  222.             else 
  223.                 theMenuItem :=  _match([menuItem t:pMyFont m:[menu t:gCurrFontMenu[1]]]!,1);
  224.             if(theMenuItem)
  225.             begin    
  226.                 if not(theMenuItem.e)
  227.                 begin
  228.                     myReturn := -1;        # disabled menuItem - expected that can't be selected
  229.                     failStr := "MenuItem is disabled so it couldn't be selected";
  230.                 end;
  231.             end;
  232.             else
  233.             begin
  234.                 myReturn := returnVal;
  235.                 failStr := "Couldn't select menuItem, it is not present.";
  236.             end;
  237.         end;
  238.  
  239.         TCSEnd( {1, global kTCSetFont}, myReturn,failStr,pObjectNumber,pMyFont);
  240.     end;
  241.     else
  242.         LogStr("Sorry, can't locate the font menu.  Is the gFontList set up correctly?");
  243.     return(returnVal);
  244. end; # SetFont()
  245.  
  246. #########################################################################
  247. #                        SetStyle(pMyStyle, pObjectNumber)
  248. #========================================================================
  249. # Author:        KTA
  250. # Description:    Sets the currently selected font style to <pMyStyle> 
  251. # Parameters:    pMyStyle - Name of the Style.
  252. #                pObjectNumber - Integer used to track all elements that make up 
  253. #                                an Font record - TCS related.
  254. # Returns:        returns what SelectMenuItem returns 
  255. #                    0 - failure
  256. #                    String - success
  257. # Examples:        SetStyle('Bold');
  258. # Assumptions:    That InitFonts() has been called thus global gCurrStyleMenu
  259. #                is set to the name of the menus which contain <pMyStyle>
  260. #========================================================================
  261. # History:
  262. # KTA 7/8/93    gCurrStyleMenu update for intl
  263. # KTA 7/23/93    gCurrStyleMenu - Help insure that it is initilized correctly
  264. # KTA 7/30/93    TCSReturn -1 if menuItem is not enabled
  265. # KTA 8/24/93    TCS stack parity check
  266. # KTA 5/12/94    Wasn't handling disabled menuItems correctly.
  267. # ML 12/01/94    Added exception handling support
  268. #########################################################################
  269. TASK SetStyle(pMyStyle := '', pObjectNumber := 'NA') 
  270. begin
  271.     failStr := "";
  272.     returnVal := 0;
  273.     if not(global gCurrStyleMenu)                # Menu(s) which contain the menu item
  274.     begin
  275.         if (global gFontStyleList[1])
  276.             gCurrStyleMenu := FindMenu(global gFontStyleList[1]);    
  277.         if not(gCurrStyleMenu)                # Help insure that it is initilized correctly
  278.             gCurrStyleMenu := FindMenu('Bold');
  279.     end;
  280.     if (gCurrStyleMenu) 
  281.     begin
  282.         TCSStart({ 3, global kTCSetFont},"SetStyle");        # Start TCS
  283.         returnVal := SelectMenuItem(pMyStyle,gCurrStyleMenu[1],gCurrStyleMenu[2]);    # Select the font from the Font menu
  284.         if (returnVal)
  285.             myReturn := 1;
  286.         else    # No returnVal - SelectMenuItem failed
  287.         begin
  288.             if (gCurrStyleMenu[2])
  289.                 theMenuItem :=  _match([menuItem t:pMyStyle m:[menuItem t:gCurrStyleMenu[1] m:[menu t:gCurrStyleMenu[2]]]]!,1);
  290.             else 
  291.                 theMenuItem :=  _match([menuItem t:pMyStyle m:[menu t:gCurrStyleMenu[1]]]!,1);
  292.             if(theMenuItem)
  293.             begin    
  294.                 if not(theMenuItem.e)
  295.                 begin
  296.                     myReturn := -1;        # disabled menuItem - expected that can't be selected
  297.                     failStr := "MenuItem is disabled so it couldn't be selected";
  298.                 end;
  299.             end;
  300.             else
  301.             begin
  302.                 myReturn := returnVal;
  303.                 failStr := "Couldn't select menuItem, it is not present.";
  304.             end;
  305.         end;
  306.         
  307.         TCSEnd({ 3, global kTCSetFont }, myReturn,failStr,pObjectNumber,pMyStyle);
  308.     end;
  309.     else
  310.         LogStr("Sorry, can't locate the style menu.  Is the gFontStyleList set up correctly?");
  311.     return(returnVal);
  312. end; # SetStyle()
  313.  
  314. #########################################################################
  315. #                        SetSize(pMySize, pObjectNumber)
  316. #========================================================================
  317. # Author:        KTA
  318. # Description:    Sets the currently selected font size to <pMySize> 
  319. # Parameters:    pMySize - Name of the size.
  320. #                pObjectNumber - Integer used to track all elements that make up 
  321. #                                an Font record - TCS related.
  322. # Returns:        returns what SelectMenuItem returns 
  323. #                    0 - failure
  324. #                    String - success
  325. # Examples:        SetSize('10');
  326. # Assumptions:    That InitFonts() has been called thus global gCurrSizeMenu
  327. #                is set to the name of the menus which contain <pMySize>
  328. #========================================================================
  329. # History:
  330. # KTA 7/8/93    gCurrSizeMenu update for intl
  331. # KTA 7/30/93    TCSReturn -1 if menuItem is not enabled
  332. # KTA 8/24/93    TCS stack parity check
  333. # KTA 5/12/94    Wasn't handling disabled menuItems correctly.
  334. # ML 12/01/94    Added exception handling support
  335. #########################################################################
  336. TASK SetSize(pMySize := '', pObjectNumber := 'NA') 
  337. begin
  338.     failStr := '';
  339.     returnVal :=0;
  340.     if not(global gCurrSizeMenu)                # Menu(s) which contain the menu item
  341.         gCurrSizeMenu := FindMenu(global gFontSizeList[1]);         
  342.     if (gCurrSizeMenu) 
  343.     begin
  344.         TCSStart({ 2, global kTCSetFont },"SetSize");        # Start TCS
  345.         returnVal := SelectMenuItem(pMySize,gCurrSizeMenu[1],gCurrSizeMenu[2]);    # Select the font from the Font menu
  346.         if (returnVal)
  347.             myReturn := 1;
  348.         else    # No returnVal - SelectMenuItem failed
  349.         begin
  350.             if (gCurrSizeMenu[2])
  351.                 theMenuItem :=  _match([menuItem t:pMySize m:[menuItem t:gCurrSizeMenu[1] m:[menu t:gCurrSizeMenu[2]]]]!,1);
  352.             else 
  353.                 theMenuItem :=  _match([menuItem t:pMySize m:[menu t:gCurrSizeMenu[1]]]!,1);
  354.             if(theMenuItem)
  355.             begin    
  356.                 if not(theMenuItem.e)
  357.                 begin
  358.                     myReturn := -1;        # disabled menuItem - expected that can't be selected
  359.                     failStr := "MenuItem is disabled so it couldn't be selected";
  360.                 end;
  361.             end;
  362.             else
  363.             begin
  364.                 myReturn := returnVal;
  365.                 failStr := "Couldn't select menuItem, it is not present.";
  366.             end;
  367.         end;
  368.             
  369.         TCSEnd({ 2, global kTCSetFont }, myReturn,failStr,pObjectNumber,pMySize);
  370.     end;
  371.     else
  372.         LogStr("Sorry, can't locate the size menu.  Is the gFontSizeList set up correctly?");
  373.     return(returnVal);
  374. end; # SetSize()
  375.  
  376. #########################################################################
  377. #                        NextLine()
  378. #========================================================================
  379. # Author:        KTA
  380. # Description:    Prepares application to accept the next line of text
  381. # Parameters:    None
  382. #                gNextLineMethod = 
  383. #                    1 - ReturnKey
  384. #                    2 - Enter Key
  385. #                    3 - Down Arrow Key
  386. #                    4 - Tab Key
  387. #                    {<Optional Specifier>} - if no specifier will select the 
  388. #                        first document window with close and grow box.
  389. # Returns:        Nada
  390. # Examples:        NextLine();
  391. # Assumptions:    global gNextLineMethod is set to the correct method required for 
  392. #                preparing the application to accept the next line of text.
  393. #========================================================================
  394. # History:
  395. #
  396. #########################################################################
  397. TASK NextLine() begin
  398.     global gNextLineMethod;
  399.     ### For more than 1 line of text a new line must be selected
  400.     if (TypeOf(gNextLineMethod) = 'integer')
  401.     begin
  402.         ### Cases of Keystrokes to move to next line
  403.         if (gNextLineMethod = 1)                            # 1 - ReturnKey
  404.             SpecialKey(returnKey,"Return Key");
  405.         else if (gNextLineMethod = 2)                        # 2 - EnterKey
  406.             SpecialKey(enterKey,"Enter Key");
  407.         else if (gNextLineMethod = 3)                        # 3 - DownArrow Key
  408.             SpecialKey(downarrowKey,"Down Arrow Key");
  409.         else if (gNextLineMethod = 4)                        # 4 - TabKey
  410.             SpecialKey(tabKey,"Tab Key");
  411.     end;
  412.     else 
  413.     begin
  414.         #you want random move and click
  415.         if(gNextLineMethod = {})                            # {} - Move/Click
  416.             whichWindow := 0;
  417.         else
  418.             whichWindow := gNextLineMethod[1];                # {} - Move relative to the window <gNextLineMethod[1]> then Click
  419.         
  420.         MoveRelativeToWindow('random','random',whichWindow,2,{60,60,30,30});        #move pointer to a random
  421.     end;
  422. end; # NextLine()
  423.  
  424.  
  425. #########################################################################
  426. #                        RandomFontRecords(pCurrentFontRecord)
  427. #========================================================================
  428. # Author:        KTA
  429. # Description:    Creates random font records based on the globals: gFontList,
  430. #                gFontSizeList, gFontStyleList. 
  431. # Parameters:    pCurrentFontRecord - The script writer can define a partial record
  432. #                                    and a complete record will be returned.
  433. # Returns:        pCurrentFontRecord := {FontName, SizeName,{StyleName1, StyleName2}};
  434. # Examples:        RandomFontRecords(); may return - {'Geneva','12'{'Bold','Italic'}}
  435. # Assumptions:    
  436. #========================================================================
  437. # History:
  438. #
  439. #########################################################################
  440. TASK RandomFontRecords(pCurrentFontRecord := {"","",""})
  441. begin
  442.     global gFontList, gFontSizeList, gFontStyleList;
  443.     if (pCurrentFontRecord[1] = "")
  444.     begin
  445.         ### Font assignment ####
  446.         whichFont := Random(1,Card(gFontList));                    # Random font position
  447.         currentFont := gFontList[whichFont];                    # Assign font from random position in list
  448.          # Replace old font with new
  449.         pCurrentFontRecord := ReplaceFont(currentFont,pCurrentFontRecord);
  450.     end;
  451.     if (pCurrentFontRecord[2] = "")
  452.     begin
  453.         ### Size assignment ####
  454.         whichSize := Random(1,Card(gFontSizeList));                # Random size position
  455.         currentSize := gFontSizeList[whichSize];                # Assign size from random position in list
  456.          # Replace old size with new
  457.          pCurrentFontRecord := ReplaceFontSize(currentSize,pCurrentFontRecord);
  458.     end;
  459.     if (pCurrentFontRecord[3] = "")
  460.     begin
  461.         if (gFontStyleList)        # Insure that gFontStyleList is defined
  462.         begin
  463.             ### Style assignment ####
  464.             availStyleList := gFontStyleList;                        # Assign global gFontStyleList to a temp value
  465.             styleList := {};                                        # Init the styleList
  466.             for numStyle := 1 to (Random(1, Card(availStyleList)))    # Add random number of styles (from 1 to random numbr of styles avail)
  467.             begin
  468.                 RandNum := Random(1,Card availStyleList);            # Select a random style from list of available styles
  469.                 styleList := Insert(availStyleList[RandNum],(Card(StyleList)+1),StyleList);    #Insert the random style into the end of the current Style list
  470.                 availStyleList := Remove(RandNum,availStyleList);        # Remove the Style from available Styles
  471.             end;
  472.             # Replace old StyleList with new
  473.             pCurrentFontRecord := ReplaceFontStyle(StyleList,pCurrentFontRecord);
  474.         end;
  475.     end;
  476.     return( pCurrentFontRecord );    
  477. end; # RandomFontRecords()
  478.  
  479.  
  480. #########################################################################
  481. #                        WaterFallFontTest()
  482. #========================================================================
  483. # Author:        KTA
  484. # Description:    Creates and executes font records based on the globals: gFontList,
  485. #                gFontSizeList, gFontStyleList. For each Font, each defined size will 
  486. #                be selected, with each of the defined styles. 
  487. # Parameters:    None
  488. # Returns:        nada
  489. # Examples:        WaterFallFontTest();
  490. # Assumptions:    global gPlainStyle is defined as the Plain style menu item
  491. #========================================================================
  492. # History:
  493. #
  494. #########################################################################
  495. TASK WaterFallFontTest() 
  496. begin
  497.     global gFontList, gFontSizeList, gFontStyleList,gPlainStyle,gCurrFontMenu,gCurrStyleMenu,
  498.     gCurrSizeMenu,gNextLineMethod,gNextLineClearsFontSettings, gFontObject;
  499.     styleList := {};                                    # Init styleList
  500.     currentFontRecord := {"","",""};                    # Init currentFontRecord
  501.     resetPlainFlag := 1;                                # Init resetPlainFlag
  502.     if (gNextLineClearsFontSettings)                    # Does method of moving to the next line clear the font settings
  503.     begin
  504.         completeRecord := 1;                            # If it does we need a complete record
  505.         resetPlainFlag := 0;                            # we also don't need to reset the styles to plain
  506.     end;
  507.     ### Font assignment ####
  508.     for each currentFont in gFontList                     # Do this for all the fonts in global gFontList.
  509.     begin
  510.         gFontObject := gFontObject + 1;  # Increment the object number for TCS info
  511.         currentFontRecord := ReplaceFont(currentFont,currentFontRecord); # Place current font into current fontRecord
  512.         continueFlag := 1;
  513.         ### Size assignment ####
  514.         for each currentSize in gFontSizeList             # Do this for each size in global gFontSizeList
  515.         begin
  516.             if (continueFlag)
  517.             begin
  518.                 currentFontRecord := ReplaceFontSize(currentSize,currentFontRecord); # Place current size into current fontRecord
  519.                 if(resetPlainFlag)    and (gPlainStyle)        # Do we want to reset the styles to plain between style selection
  520.                     Call (global gSetStyle, gPlainStyle,gFontObject);
  521.                 ### Style assignment ####        
  522.                 styleList := {};                            # ReInit styleList because we have a new size to deal with
  523.                 if (Card(gFontStyleList) > 0)                # gFontStyleList needs to contain items
  524.                 begin
  525.                     for each currentStyle in gFontStyleList     # Do this for all style defined in global gFontStyleList
  526.                     begin
  527.                         if (continueFlag)
  528.                         begin
  529.                             if not(completeRecord)            # if we move to a random location and click all styles will be cleared so we want to have a complete list
  530.                                 styleList := {};                    # ReInit Stylelist because previous style will still be selected
  531.                             styleList := insert(currentStyle,(Card(StyleList)+1),styleList);        # Build current styleList
  532.             
  533.                             currentFontRecord := ReplaceFontStyle(StyleList, currentFontRecord);     # Place current styleList into current fontRecord
  534.                                     FontRecord := SetFontParams(currentFontRecord,0,gFontObject);
  535.                                     If(FontRecord)
  536.                                     begin
  537.                                         ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject);    # Match and report back what is actually selected
  538.                                         Println "• - ",FontRecord;
  539.                                     end;
  540.                                     else
  541.                                     begin
  542.                                         Println "NOTE: Couldn't complete FontRecord • - ", currentFontRecord;
  543.                                         continueFlag := 0;
  544.                                     end;
  545.                             if not(completeRecord)                        # If we don't need a complete record
  546.                                 currentFontRecord := {"","",""};        # Reinitialize so were only passing a Style and not a complet record
  547.                         end;
  548.                     end;
  549.                 end;
  550.                 else    # Handle an empty gFontStyleList
  551.                 begin
  552.                     FontRecord := SetFontParams(currentFontRecord,0,gFontObject);
  553.                     ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu},gFontObject);    # Match and report back what is actually selected
  554.                     Println "• - ",FontRecord;
  555.                 end;
  556.             end;
  557.         end;
  558.     end;
  559. end; # WaterFallFontTest()
  560. (*
  561. #########################################################################
  562. #                        QuickLookTextTest()
  563. #========================================================================
  564. # Author:        KTA
  565. # Description:    Creates and executes font records based on the globals: gFontList,
  566. #                gFontSizeList, gFontStyleList. For each Font will select 
  567. #                random size and random number of styles.
  568. # Parameters:    none
  569. # Returns:        nada
  570. # Examples:        QuickLookTextTest();
  571. # Assumptions:    global gPlainStyle is defined as the Plain style menu item
  572. #========================================================================
  573. # History:
  574. #
  575. #########################################################################
  576. TASK QuickLookTextTest() 
  577. begin
  578.     global gFontList, gFontSizeList, gFontStyleList,gCurrStyleMenu,gNextLineMethod;
  579.     styleList := {};                                    # Init styleList
  580.     currentFontRecord := {"","",""};                    # Init currentFontRecord
  581.     ### Font assignment ####
  582.     for each currentFont in gFontList                     # Do this for all the fonts in global gFontList.
  583.     begin
  584.         currentFontRecord := ReplaceFont(currentFont,currentFontRecord); # Place current font into current fontRecord
  585.         
  586.         ### Size assignment ####
  587.         whichSize := Random(1,(Card gFontSizeList));            # Random Size
  588.         currentSize := gFontSizeList[whichSize];
  589.             currentFontRecord := ReplaceFontSize(currentSize,currentFontRecord); # Place current size into current fontRecord
  590.  
  591.         ### Style assignment ####
  592.         availStyleList := gFontStyleList;                        # Assign global gFontStyleList to a temp value
  593.         styleList := {};                                        # Init the styleList
  594.         for numStyle := 1 to (Random(1, Card(availStyleList)))    # Add random number of styles (from 1 to random numbr of styles avail)
  595.         begin
  596.             RandNum := Random(1,Card availStyleList);            # Select a random style from list of available styles
  597.             styleList := Insert(availStyleList[RandNum],(Card(StyleList)+1),StyleList);    #Insert the random style into the end of the current Style list
  598.             availStyleList := Remove(RandNum,availStyleList);        # Remove the Style from available Styles
  599.         end;
  600.         # Replace old StyleList with new
  601.         currentFontRecord := ReplaceFontStyle(StyleList,currentFontRecord);
  602.         println "The current font record is: ",currentFontRecord;
  603.         SetFontParams(currentFontRecord);
  604.     end;
  605. end; # QuickLookTextTest()
  606. *)
  607. #########################################################################
  608. #                        SetFontParams(pFontRecord, pResetPlainFlag, pObjectNumber)
  609. #========================================================================
  610. # Author:        KTA
  611. # Description:    Executes font records bycalling the routines necessary for  selecting 
  612. #                the font (pFontRecord[1]) if its defined, selecting the size 
  613. #                (pFontRecord[2]) if its defined, then selecting each style defined
  614. #                in the styleRecord (pFontRecord[3]). ReportSelectedMenuItems is then
  615. #                called to report all of the menu items in the appropriate menus 
  616. #                with a MarkChar.
  617. # Parameters:    pFontRecord- {Font,Size,{Style1,Style2}}
  618. #                pResetPlainFlag - 
  619. #                    1 - Select <gPlainStyle> before executing the StyleRecord
  620. #                     loop so styles will begin at a cleared state.
  621. #                    0 - Won't select the plain menu item.
  622. #                pObjectNumber - Integer used to track all elements that make up 
  623. #                                an Font record - TCS related.
  624. # Returns:        By default,  returns what SetStyle returns 
  625. # Examples:        SetFontParams();
  626. # Assumptions:    global gPlainStyle is defined as the Plain style menu item
  627. #========================================================================
  628. # History:
  629. #
  630. #########################################################################
  631. TASK SetFontParams(pFontRecord,pResetPlainFlag := 1, pObjectNumber)
  632. begin
  633.     returnVal := 0;
  634.     #Println "• - pFontRecord is: ",pFontRecord;
  635.     global gPlainStyle;        # Init globals
  636.     if (pFontRecord[1])                                       # If we passed in a Font
  637.         returnVal:= call (global gSetFont, pFontRecord[1],pObjectNumber);            # Set the Font
  638.     if not(pFontRecord[1])    or ((pFontRecord[1]) and (returnVal))    # don't want to continue if font selection failed.
  639.     begin
  640.         if (pFontRecord[2])                                # If we passed in a Size
  641.             returnVal := call (global gSetSize, pFontRecord[2],pObjectNumber);        # Set the Size
  642.     
  643.         if (pResetPlainFlag) and (gPlainStyle)
  644.             returnVal := call (global gSetStyle, gPlainStyle,pObjectNumber);            # Reset to plain
  645.     
  646.         styleRecord := pFontRecord[3];                    # Define the StyleRecord
  647.         if(styleRecord)
  648.         begin
  649.             for each currentStyle in styleRecord             # For all the Styles
  650.                 returnVal := call (global gSetStyle, currentStyle,pObjectNumber);    # Set the Style
  651.         end;
  652.     end;
  653.     if(returnVal)
  654.         returnVal := pFontRecord;
  655.     return(returnVal);
  656. end; # SetFontParams()
  657.             
  658. #########################################################################
  659. #                        ReportSelectedMenuItems(pMenuList, pObjectNumber)
  660. #========================================================================
  661. # Author:        KTA
  662. # Description:    Collects all the menu items with a markChar ('') from the 
  663. #                defined menus defined in pMenuList. Then types each marked item 
  664. #                and calls NextLine() to move to the next text entry line.
  665. # Parameters:    pMenuList - List of lists/strings 
  666. #                    List of menus containing marked menuitems. 
  667. #                pObjectNumber - Integer - used to track all elements that make up 
  668. #                                an Font record - TCS related.
  669. # Returns:        nada
  670. # Examples:        ReportSelectedMenuItems({{'Format','Font'},{'Format','Styles'});
  671. # Assumptions:    
  672. #========================================================================
  673. # History:
  674. # KTA    7/8/93    Check to see if duplicate items in pMenuList
  675. # KTA    8/24/93    TCS stack parity check
  676. # KTA    9/21/93    Removed gHandleTextEntry
  677. # ML 12/01/94    Added exception handling support
  678. # KTA 2/12/95    Added gReportSelectedMenuItemsHook1
  679. # KTA 2/21/95    Removed gReportSelectedMenuItemsHook1
  680. # KTA 2/24/95    Added default of '' for pObjectNumber to avoid vu errors
  681. #                The reason we use '' is that nothing will be put in the numeric
  682. #                field within Phoenix.
  683. # KTA 2/24/95    Check to see if globa gNextLine is defined before calling it.
  684. # ML  11/13/95    pass params into gReportSelectedMenuItems
  685. #########################################################################
  686. TASK ReportSelectedMenuItems(pMenuList, pObjectNumber := '') 
  687. begin
  688.     if global gReportSelectedMenuItems
  689.         call (gReportSelectedMenuItems, pMenuList, pObjectNumber);
  690.     else # if no custom Task for reporting selected
  691.     begin
  692.         failStr := '';
  693.         markChar := '';                                # MARK CHAR
  694.         selectedItems := "";                            # Init selectedItems
  695.                     
  696.         ##Check to see if duplicate items in pMenuList
  697.         tempMenuList := {};
  698.         for each menuRec in pMenuList
  699.         begin
  700.             if not(isMember(menuRec, tempMenuList))
  701.                 tempMenuList := Insert(menuRec, Card(tempMenuList)+1, tempMenuList);
  702.         end;
  703.         pMenuList := tempMenuList;
  704.         
  705.         for each menuRecord in pMenuList 
  706.         begin
  707.             currentMenu := 0;                            # reinitialize the currentmenu
  708.             if not(TypeOf(menuRecord) = 'list')        # Single menu item
  709.                 currentMenu := menuRecord;
  710.             else if not(menuRecord[2])                # Menu is not hierarchical
  711.                 currentMenu := menuRecord[1];
  712.             else                                         # Menu is hierarchical
  713.                 activeList := _collect([menuItem c:markChar m:[menuitem t:menuRecord[1] m:[menu t:menuRecord[2]]]]!,1);
  714.     
  715.             if(currentMenu)
  716.                 activeList := _collect([menuItem c:markChar m:[menu t:currentMenu]]!,1);
  717.             for each style in activeList 
  718.             begin
  719.                 selectedMenuItem := style.t;
  720.                 selectedItems := "{selectedItems}-{selectedMenuItem}";        # Build the list of selected menu items
  721.             end;
  722.         end;
  723.         TCSStart({ 4, global kTCSetFont },"Type SelectedItems String");                # Start TCS
  724.         
  725.         if(selectedItems)
  726.         begin
  727.             TypeStr(selectedItems);                            # Type the selected menu items
  728.             TCSFlag := 1;                                    # Pass the TCS
  729.         end;
  730.         else
  731.             TCSFlag := 0;                                    # Fail the TCS
  732.         
  733.         DialogReturn := DialogCheck("",1);                # Check to see if a dialog appeared
  734.         if (DialogReturn)
  735.         begin
  736.             TCSFlag := 0;                                # Fail the TCS
  737.             failStr := DialogReturn;                    # Set failStr to the string DialogCheck() returns
  738.         end;
  739.         TCSEnd({ 4, global kTCSetFont }, TCSFlag, failStr,pObjectNumber, selectedItems);
  740.     end; # if no custom Task for reporting selected
  741.     if(global gNextLine)
  742.         call (global gNextLine);                                        # Move to the next line
  743. end; # ReportSelectedMenuItems()
  744.